package 力扣_算法题综合.笔试题;

import java.util.Arrays;

/**
 * @author zx
 * @create 2022-08-17 20:49
 */
public class 最长连续序列_119 {
    public int longestConsecutive(int[] nums) {
        Arrays.sort(nums);
        int len = 1, res = 1;
        for(int i = 1; i < nums.length; i++) {
            if (nums[i] == nums[i - 1] + 1){
                len++;
            }else{
                len = 1;
            }
            res = Math.max(res, len);
        }
        return res;
    }
}
